#include <bits/stdc++.h>

using namespace std;

int n,a[100001],b[100001],m,cnt,z=-1;

int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int T;
    cin>>T;
    for(int i=1;i<=T;i++)
    {
        for(int j=1;j<=z;j++)
        {
            a[j]=0;
        }
        z=-1;
        cnt=0;
        cin>>n;
        for(int j=1;j<=n;j++)
        {
            cin>>m;
            if(m>z)
            {
                z=m;
            }
            a[m]++;
            if(a[m]==2)
            {
                cnt+=m;
            }
        }
        cout<<cnt<<endl;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
